#include "FiniteStateMachine.h"

#include <string>

using namespace std;

FiniteStateMachine::FiniteStateMachine(void)
{
	_hasher = new TypeMap();
}

FiniteStateMachine::~FiniteStateMachine(void)
{
	for(TypeMap::iterator it = _hasher->begin(); it != _hasher->end(); ++it)
		delete (*it).second;
	delete _hasher;
}

std::string const * FiniteStateMachine::getClassName(){
	return new std::string("FiniteStateMachine");
}

int FiniteStateMachine::set(const char * varName, void * varValue){
	if(_hasher->find(varName) != _hasher->end()){
		_hasher->erase(varName);
	}
	(*_hasher)[varName] = varValue;
	return 1;
}

void * FiniteStateMachine::get(const char * varName){
	if(_hasher->find(varName) != _hasher->end())
		return (*_hasher)[varName];
	return 0;
}

int FiniteStateMachine::setInt(const char * varName, int value){
	int * nValue = new int(value);
	void * var = (void *)nValue;
	return set(varName, var);
}

int FiniteStateMachine::getInt(const char * varName){
	void * var = get(varName);
	return *((int *)var);
}
